/**
 * Created by 69466 on 2022/05/28.
 */
 import React, {Component} from 'react';
 import {StyleSheet} from 'react-native';
 import {
   Button,
   Dialog,
   Text,
   View,
 } from 'react-native-ui-lib';
 import {isIPhoneX} from '../../../configs/platform';
 import {commonStyles} from '../../../configs/commonStyle';
 
 export default class InfoDialog extends Component {
   constructor(props) {
     super(props);
     this.state = {
       isOpen: false,
       info: '',
       showHeader: true,
       title: '提示'
     };
   }
 
   show = (info, title = '提示') => {
     this.setState({isOpen: true, title, info});
   };
 
   dismiss = () => {
     this.setState({isOpen: false});
   };
 
   renderPannableHeader = props => {
     const {title} = props;
     return (
       <View>
         <View margin-10 center>
           <Text style={{...commonStyles.text_black_18}}>{title}</Text>
         </View>
         <View height={1} bg-line />
       </View>
     );
   };
 
   render() {
     const {isOpen, showHeader, title, info} = this.state;
     const renderPannableHeader = showHeader
       ? this.renderPannableHeader
       : undefined;
     return (
       <Dialog
         migrate
         useSafeArea
         containerStyle={styles.dialog}
         visible={isOpen}
         width={'70%'}
         onDismiss={this.dismiss}
         renderPannableHeader={renderPannableHeader}
         pannableHeaderProps={{title}}>
         <View style={styles.info}>
           <Text>{info}</Text>
         </View>
         <View row style={{borderTopColor: '#eeeeee', borderTopWidth: 1}}>
           <Button
             flex
             background-white
             labelStyle={{color: '#666666'}}
             text14
             label={'关闭'}
             onPress={() => {
               this.dismiss();
               this.props.cancalClick && this.props.cancalClick();
             }}
           />
         </View>
       </Dialog>
     );
   }
 }
 
 const styles = StyleSheet.create({
   dialog: {
     backgroundColor: 'white',
     marginBottom: isIPhoneX ? 0 : 20,
     borderRadius: 4,
   },
   info: {
     minHeight: 150,
     padding: 20,
     width: '80%'
   },
 });
 